﻿using NUnit.Framework;

namespace InvoiceInvoker.Logic.Tests
{
	[TestFixture]
	public class RegisteredProductTests
	{
		[Test, Sequential]
		public void GeneratesProduct([Values("10 %", "10%", "n/a")] string vatRate, [Values(2, 2, 0)] double expectedVatValue, [Values(22, 22, 20)] double expectedGrossValue)
		{
			RegisteredProduct registeredProduct = new RegisteredProduct();
			registeredProduct.Name = "TestProduct";
			registeredProduct.Pkwiu = "12.34";
			registeredProduct.MeasureUnit = "szt.";
			registeredProduct.NetPrice = 10M;
			registeredProduct.VatRate = vatRate;

			Product product = registeredProduct.ToProduct(2M);

			Assert.AreEqual("TestProduct", product.Name);
			Assert.AreEqual("12.34", product.Pkwiu);
			Assert.AreEqual(2M, product.Quantity);
			Assert.AreEqual("szt.", product.MeasureUnit);
			Assert.AreEqual(10M, product.NetPrice);
			Assert.AreEqual(20M, product.NetValue);
			Assert.AreEqual(vatRate, product.VatRate);
			Assert.AreEqual((decimal)expectedVatValue, product.VatValue);
			Assert.AreEqual((decimal)expectedGrossValue, product.GrossValue);
		}
	}
}
